package com.cupcorn.lib.display;

import org.andengine.entity.scene.Scene;

import com.cupcorn.lib.game.GameAutoParallax;
import com.cupcorn.lib.game.GameEngine;
import com.cupcorn.lib.game.element.GameElementAutoParallax;

public class DisplayAutoParallax
{
	GameEngine			engine;
	GameElementAutoParallax[]	gameElementSprite;
	GameAutoParallax[]		sprite;
	
	public DisplayAutoParallax(final GameEngine engine, GameElementAutoParallax[] gameElementSprite)
	{
		this.engine = engine;
		this.gameElementSprite = gameElementSprite;
		sprite = new GameAutoParallax[gameElementSprite.length];
	}
	
	public GameAutoParallax newSprite(int index)
	{
		return newSprite(index, engine.getEngine().getScene());
	}
	
	public GameAutoParallax newSprite(int index, Scene scene)
	{
		GameAutoParallax sprite = sprite(index);
		scene.setBackground(sprite);
		return sprite;
	}
	
	public GameAutoParallax sprite(int index)
	{
		sprite[index] = new GameAutoParallax(gameElementSprite[index].getRed(), gameElementSprite[index].getGreen(), gameElementSprite[index].getBlue(), gameElementSprite[index].getChangePerSecond());
		return sprite[index];
	}
	
	public GameAutoParallax getSprite(int index)
	{
		return sprite[index];
	}
}
